using System;
using System.Reflection;
using System.Web.UI;
using SubversionReports.Utilities;

namespace SubversionReports.Web
{
    public partial class Default : MasterPage
    {
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            LogoutButton.Visible = SvnWebDav.AuthenticationSuceeded;
            VersionLabel.Text = string.Format("Powered by Subversion Reports :: Version {0}", Assembly.GetExecutingAssembly().GetName().Version);
            if (Request.PhysicalApplicationPath.StartsWith("/"))
            {
                MonoPoweredIcon.Visible = true;
                MonoPoweredIcon.Attributes.Add("style", "margin: 2px;");
            }
            UrchinPlaceHolder.Visible = Request.Url.Host.ToLower().Contains("subersionreports.org");
        }

        /// <summary>
        /// Handles the Click event of the LogoutButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void LogoutButton_Click(object sender, EventArgs e)
        {
            Session.RemoveAll();
            Session.Abandon();
            Response.Redirect(Request.ApplicationPath);
        }
    }
}
